home *** CD-ROM | disk | FTP | other *** search
- /* NCRDriver.h */
- /*
- * NCRDriver.h
- * Copyright © 1994 Apple Computer Inc. All rights reserved.
- */
- /* .___________________________________________________________________________________.
- | This is the public interface to the sample driver. This file should be included |
- | in application programs that use the driver. (The test program includes the |
- | private headers for debugging). |
- | |
- | NCRDriver is a sample device driver for a PCI interface card. It supports the |
- | NCR 8250 interface card and the NCR 53C825 SCSI bus interface chip. This driver |
- | was written to illustrate PCI device driver programming, and should not be taken |
- | as an example, either of a production driver (it is too inefficient) or of a SCSI |
- | device driver. |
- .___________________________________________________________________________________.
- */
- /*
- * The following PBControl requests are unique to the PCI Sample Driver:
- *
- * kControlDoSCSIBusReset Reset the SCSI bus. csParam values are ignored.
- * kControlGetOrSetInitiatorID Access the Initiator ID. csParam[0] has the new ID or
- * gets the current ID.
- * To execute a SCSI Command, an application provides SCSI-specific parameters in
- * a NCRSCSIParam record, stores the address of this record in the ioMisc field of
- * IOParam record, provides the user buffer address and transfer length, and executes
- * PBRead or PBWrite. For example,
- * myNCRParam.driverAction = kNCRDriverInputAllowed;
- * myNCRParam.targetID = <SCSI Bus ID>;
- * myNCRParam.logicalUnitNumber = 0;
- * myNCRParam.scsiCommand[0..11] = <SCSI command bytes>;
- * myNCRParam.scsiCommandLength = <length of SCSI Command>;
- * myNCRParam.watchdogTimeout = <timeout in MSec>
- *
- * myIOPB.ioRefNum = <NCR Driver RefNum from OpenDriver>;
- * myIOPB.ioVersNum = <ignored, use zero>;
- * myIOPB.ioPermissn = <ignored, use zero>;
- * myIOPB.ioMisc = (Ptr) &myNCRParam;
- * myIOPB.ioBuffer = <data buffer, NULL if none>;
- * myIOPB.ioReqCount = <transfer count, zero if none>;
- * myIOPB.ioActCount = <will be set by the I/O request>;
- * myIOPB.ioPosMode = ioMapBuffer; <Note: currently undefined>
- * myIOPB.ioPosOffset = <ignored, use zero>;
- *
- * The driver returns status codes defined in <scsi.h>
- */
- #ifndef __NCRSCSIDriver__
- #define __NCRSCSIDriver_
- #include <Types.h>
- #include <OSUtils.h>
- #include <Files.h>
-
- #define kDriverNamePString "\p.NCRSCSIDriver" /* Driver name: Pascal string */
- #define kDriverNameCString ".NCRSCSIDriver" /* Driver name: C string */
-
- #ifndef REZ
- /*
- * Public PBControl codes we can't find in the headers.
- */
- enum {
- driverPowerLow = 47,
- driverPowerHigh = 48
- };
- /*
- * NCR SCSI Driver private PBControl and PBStatus csCodes.
- */
- enum {
- kControlDoSCSIBusReset = 1024, /* PBControl, no csCode fields set */
- kControlGetOrSetInitiatorID, /* NCRDriverInitiatorIDParam */
- kControlDoSCSIRundown /* Attempt to stabalize the SCSI bus */
- };
-
- #define kNoSCSITimeout 0 /* For watchdogTimeout parameter */
-
- /*
- * Values for the driverAction parameter for the PBRead/PBWrite NCRSCSIParam command.
- * Note: the NCR script relies on these particular values.
- */
- enum {
- kNCRDriverNoDataPhase = 0, /* PBRead, TestUnitReady or similar */
- kNCRDriverInputAllowed = 1, /* PBRead, RequestSense, Read, or similar */
- kNCRDriverOutputAllowed = 2, /* PBWrite, Write, Mode Select, or similar */
- kNCRDriverActionMask = 0x07 /* Allowance bits */
- };
-
- #define kNCRMemoryTestBusID (65535)
-
- /*
- * This is passed in the ioMisc field of a PBRead or PBWrite command.
- * Note the following:
- * IOParam.ioMisc Address of the NCRSCSIParam record.
- * IOParam.ioBuffer User data buffer (must not be NULL)
- * IOParam.ioReqCount User data count (must not be zero)
- * IOParam.ioActCount Actual data transfer
- * IOParam.ioPosMode Ignored
- * IOParam.ioPosOffset Ignored
- * driverAction Must correspond to PBRead or PBWrite. If the request does not
- * require a data phase (Test Unit Ready, for example), you must
- * provide a data buffer and a non-zero transfer count: this is
- * required by the Device Manager.
- * stateTag A longword passed to the LogState macro.
- *
- * The caller must supply a non-null ioBuffer and non-zero ioReqCount -- this is a
- * limitation of the Device Manager. The driver uses the driverAction parameter to
- * determine whether an I/O buffer is needed, and ignores the caller's parameters
- * if driverAction equals kNCRDriverNoDataPhase.
- *
- * If the targetID == kNCRMemoryTestBusID the driver runs a test script that does not
- * access remote SCSI devices. Two tests may be run:
- * memory move test Copy data between the IOParam.ioBuffer and a buffer
- * defined by memTestPhysAddress (which must be non-NULL).
- * ioReqCount bytes will be copied. (PBRead copies from
- * the memTestPhysAddress, PBWrite copies to it.). The
- * transfer burst length is in memTestBurstLength. Use one
- * of the values in NCR53C825.h.
- * interrupt test Perform a minimal NCR script that does nothing. For this
- * test, memTestPhysAddress must be NULL. The caller must
- * provide a dummy ioBuffer and non-zero ioReqCount.
- *
- * The buffer in memTestPhysAddress is computed using LockMemoryContiguous and
- * GetPhysical. It must be resident, locked, and physically contiguous.
- *
- * TBS: The caller can request an immediate interrupt test by (PBControl ...)
- *
- */
- #if STRUCTALIGNMENTSUPPORTED
- #pragma options align=power
- #endif
- struct NCRSCSIParam {
- unsigned short driverAction; /* -> Operation required */
- unsigned short targetID; /* -> SCSI Bus ID */
- unsigned short logicalUnitNumber; /* -> SCSI LUN -- not supported yet */
- unsigned char scsiCommand[12]; /* -> SCSI Command itself */
- unsigned short scsiCommandLength; /* -> 0, 6, 10, or 12 bytes */
- Duration watchdogTimeout; /* -> Msec timeout, zero = none */
- unsigned char statusByte; /* <- Command status */
- unsigned char messageByte; /* <- Command Complete message */
- UInt32 stateTag; /* -> Tag word for testing */
- PhysicalAddress memTestPhysAddress; /* <> Buffer for memory move test */
- UInt32 memTestBurstLength; /* -> Memory test configuration */
- };
- #if STRUCTALIGNMENTSUPPORTED
- #pragma options align=reset
- #endif
- typedef struct NCRSCSIParam NCRSCSIParam, *NCRSCSIParamPtr;
-
- /*
- * NCRDriverInitiatorIDParam lets the caller get and set the initiator bus ID
- * stored in non-volatile memory (NVRAM).
- *
- * PBStatus, csCode = kControlGetOrSetInitiatorID retrieves the current value.
- * PBControl, csCode = kControlGetOrSetInitiatorID stores a new value.
- */
- #if defined(powerc) || defined (__powerc)
- #pragma options align=mac68k
- #endif
- struct NCRDriverInitiatorIDParam {
- QElemPtr qLink;
- short qType;
- short ioTrap;
- Ptr ioCmdAddr;
- IOCompletionUPP ioCompletion;
- OSErr ioResult;
- StringPtr ioNamePtr;
- short ioVRefNum;
- short ioCRefNum;
- short csCode;
- unsigned short initiatorID; /* The initiator SCSI bus ID */
- };
- #if defined(powerc) || defined(__powerc)
- #pragma options align=reset
- #endif
- typedef struct NCRDriverInitiatorIDParam NCRDriverInitiatorIDParam;
- typedef NCRDriverInitiatorIDParam *NCRDriverInitiatorIDParamPtr;
-
- /*
- * NCRDriverRundownParam is intended to be called after a device timeout.
- * It attempts to bring the bus to a stable state.
- *
- * If the bus is not busy (or we are not the initiator), it does nothing.
- * Otherwise it runs the "failure" script.
- *
- */
- #if defined(powerc) || defined (__powerc)
- #pragma options align=mac68k
- #endif
- struct NCRDriverRundownParam {
- QElemPtr qLink;
- short qType;
- short ioTrap;
- Ptr ioCmdAddr;
- IOCompletionUPP ioCompletion;
- OSErr ioResult;
- StringPtr ioNamePtr;
- short ioVRefNum;
- short ioCRefNum;
- short csCode;
- Duration watchdogTimeout; /* -> Msec timeout, zero = none */
- };
- #if defined(powerc) || defined(__powerc)
- #pragma options align=reset
- #endif
- typedef struct NCRDriverRundownParam NCRDriverRundownParam;
- typedef NCRDriverRundownParam *NCRDriverRundownParamPtr;
-
- #endif /* Not REZ */
- #endif /* __NCRDriver__ */
-
-